package com.ukefu.core;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;

import com.ukefu.util.DateConverter;
import com.ukefu.webim.service.resource.ActivityResource;
import com.ukefu.webim.service.resource.BatchResource;
import com.ukefu.webim.service.resource.ContactsResource;
import com.ukefu.webim.service.resource.QualityResource;
import com.ukefu.webim.service.task.RuntimeData;
import com.ukefu.webim.web.model.JobDetail;
import com.ukefu.webim.web.model.Log;
import com.ukefu.webim.web.model.User;

public class UKDataContext {

	public static final String USER_SESSION_NAME = "user";
	public static final String CODE_SESSION_NAME = "code";
	public static final String SUPERUSER_LOGIN_SESSION_NAME = "super_user_login";//多租户下超管登录其他租户

	public static final String GUEST_USER = "guest";
	public static final String IM_USER_SESSION_NAME = "im_user";
	public static final String UKEFU_SYSTEM_DIC = "com.dic.system.template";
	public static final String UKEFU_SYSTEM_AUTH_DIC = "com.dic.auth.resource";
	public static final String UKEFU_SYSTEM_AREA_DIC ="com.dic.address.area" ;
	public static final String UKEFU_SYSTEM_ADPOS_DIC = "com.dic.adv.type" ;
	public static final String UKEFU_SYSTEM_COMMENT_DIC = "com.dic.webim.comment" ;
	public static final String UKEFU_SYSTEM_COMMENT_ITEM_DIC = "com.dic.webim.comment.item" ;
	public static final String UKEFU_SYSTEM_BTNTYPE_DIC = "com.dic.crm.btntype" ;
	public static final String UKEFU_SYSTEM_REQLOG_WARNLV = "com.dic.reqlog.warnlv" ;
	public static final String UKEFU_SYSTEM_REQLOG_ACTION = "com.dic.reqlog.aciton" ;

	public static final String UKEFU_SALES_LANG = "com.dic.sales.lang" ;

	public static final String UKEFU_SYSTEM_DIS_AI = "ownerai" ;
	public static final String UKEFU_SYSTEM_DIS_FORECAST = "ownerforecast" ;
	public static final String UKEFU_SYSTEM_DIS_AGENT = "owneruser" ;
	public static final String UKEFU_SYSTEM_ASSUSER = "assuser" ;
	public static final String UKEFU_SYSTEM_DIS_ORGAN = "ownerdept" ;
	public static final String UKEFU_SYSTEM_DIS_TIME = "distime" ;

	public static final String UKEFU_SYSTEM_COOKIES_FLAG = "uk_flagid" ;
	public static final String UKEFU_SYSTEM_NO_AI_CONFIG = "NOTEXIST" ;

	public static final String UKEFU_SYSTEM_NO_DAT = "NOTEXIST" ;

	public static final String UKEFU_SYSTEM_PRIVATEFIELD = "PRIVATEFIELD" ;

	public static final String SYSTEM_INDEX = "uckefu" ;

	public static final String CALLOUT_INDEX = "uckefu" ;

	public static final String CRM_INDEX = "uckefu" ;
	
	public static final String UKEFU_SYSTEM_SECFIELD = "ukefu_sec_field" ;


	public static final String UKEFU_SYSTEM_CALLCENTER = "callcenter";
	public static final String UKEFU_SYSTEM_WORKORDEREMAIL = "workordermail";
	public static final String UKEFU_SYSTEM_SMSEMAIL = "callcenter";
	public static final String UKEFU_SYSTEM_AI_INPUT = "inputparam";
	public static final String UKEFU_SYSTEM_AI_OUTPUT = "outputparam";

	public static final String UKEFU_SYSTEM_NOTICESMS = "noticesms";//公告短信
	public static final String UKEFU_SYSTEM_NOTICEMAIL = "noticemail";//公告邮件
	
	public static final String UKEFU_SYSTEM_REQLOGSMS = "reqlogsms";//审计日志预警短信
	public static final String UKEFU_SYSTEM_REQLOGEMAIL = "reqlogemail";//审计日志预警邮件

	public static final String UKEFU_SYSTEM_INFOACQ = "infoacq";		//数据采集模式
	public static final String GUEST_USER_ID_CODE = "R3GUESTUSEKEY" ;
	public static final String WORKORDERS_CLOSED_STATUS = "uckefu_workorders_closed" ;
	public static final String SERVICE_QUENE_NULL_STR = "service_quene_null" ;
	public static final String DEFAULT_TYPE = "default"	;		//默认分类代码
	public static final String START = "start";					//流程默认的开始节点
	public static final String CACHE_SKILL = "cache_skill_";					//技能组的缓存
	public static final String CACHE_AGENT = "cache_agent_";					//坐席列表的缓存

	public static final String CUBE_TITLE_MEASURE = "指标" ;

	public static final String UKEFU_SYSTEM_AREA = "uckefu_system_area";

	public static final String UKEFU_SYSTEM_ADV = "uckefu_system_adv";		//系统广告位

	public static final int MAX_IMAGE_WIDTH = 460 ;

	private static boolean imServerRunning = false ;			//IM服务状态

	public static final int AGENT_STATUS_MAX_USER = 10 ; 		//每个坐席 最大接待的 咨询数量

	public static final String SYSTEM_CACHE_SESSION_CONFIG = "session_config";
	
	public static final String SYSTEM_CACHE_BUSS_CONFIG = "buss_config";

	public static final String SYSTEM_CACHE_SESSION_CONFIG_LIST = "session_config_list";

	public static final String SYSTEM_CACHE_AI_CONFIG = "ai_config";

	public static final String SYSTEM_CACHE_QUALITY_CONFIG = "quality_config";

	public static final String SYSTEM_CACHE_CALLOUT_CONFIG = "callout_config";
	
	public static final String SYSTEM_CACHE_WARNING_TOUSER = "reqlogwarningtouser";

	public static final String SYSTEM_CACHE_SPT_ANSWER_KEY = "_spt_answer";

	public static final String SYSTEM_CACHE_SPT_PUB_ANSWER_KEY = "_spt_pub_answer";

	public static final String SYSTEM_CACHE_SPT_QUES_KEY = "_spt_ques";

	private static RuntimeData runtimeData = new RuntimeData();

	public static String SYSTEM_ORGI = "ukewo" ;

	public static final String USER_CURRENT_ORGI_SESSION = "current_orgi";

	public static Map<String , Boolean> model = new HashMap<String,Boolean>();

	//租户模块授权
	public static Map<String , Map<String , Boolean>> orgiModel = new HashMap<String,Map<String , Boolean>>();

	public static Map<String , Class<?>> uKeFuResourceMap = new HashMap<String , Class<?>>() ;

	public static Map<String , JobDetail> localJobDetailMap = new HashMap<String , JobDetail>() ;

	private static int WebIMPort = 8081 ;
	
	public static AtomicInteger callCenterTotal = new AtomicInteger();

	private static ApplicationContext applicationContext ;

	private static ElasticsearchTemplate templet ;

	public static BlockingQueue<Log> tempLogQueue = new LinkedBlockingQueue<Log>();

	public static final int QUALITY_ARCHIVE_DEFAULT_DAY = 3 ;

	public static final String DRIVERS_CLASS_NAME = "drivers_class_name";
	
	public static final Map<String, User> users = new HashMap<String,User>();
	
	public static final Map<String, HttpSession> sessions = new HashMap<String,HttpSession>();

	static{
		ConvertUtils.register(new DateConverter(), java.util.Date.class);

		uKeFuResourceMap.put(TaskType.ACTIVE.toString(), ActivityResource.class) ;

		uKeFuResourceMap.put(TaskType.RECOVERY.toString(), ActivityResource.class) ;

		uKeFuResourceMap.put(TaskType.BATCH.toString(), BatchResource.class) ;
		//质检分配任务
		uKeFuResourceMap.put(TaskType.QUALITY.toString(), QualityResource.class) ;
		
		//联系人
		uKeFuResourceMap.put(TaskType.CONTACTS.toString(), ContactsResource.class) ;
		
		//ai callout
		try {
			uKeFuResourceMap.put(TaskType.AISALES.toString(), Class.forName("com.ukefu.webim.service.resource.AiCalloutResource"));
		} catch (ClassNotFoundException e) {
			//e.printStackTrace();
		}
		//预测式外呼
		try {
			uKeFuResourceMap.put(TaskType.FORECAST.toString(), Class.forName("com.ukefu.webim.service.resource.ForecastCalloutResource"));
		} catch (ClassNotFoundException e) {
			//e.printStackTrace();
		}
	}

	public enum AskSectionType{
		DEFAULT ;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ActivityExecType{
		DEFAULT , RECOVERY;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AgentWorkType{
		MEIDIACHAT,
		CALLCENTER;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum SystemMessageType{
		EMAIL,SMS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	/**
	 * 名单分配状态：已分配|未分配
	 * @author iceworld
	 *
	 */
	public enum NamesDisStatusType{
		NOT,DISAGENT,DISORGAN,DISAI,DISFORECAST,WASTE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ProcessType{
		WORKORDER ;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum QuickTypeEnum{
		PUB,
		PRI;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum NamesProcessStatus{
		DIS,
		PREVIEW,
		CALLING,
		CALLED,
		CALLFAILD;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum FormFilterTypeEnum{
		BATCH,
		BUSINESS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum NameStatusTypeEnum{
		CALLED,	//已拨打
		NOTCALL,	//未拨打
		WASTE;//已作废名单
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum NamesCalledEnum{
		SUCCESS,//拨打成功
		FAILD,	//拨打失败
		NOANSWER,//无人接听
		EMPNO,	//空号
		ARREARS,//欠费
		APPO,	//预约拨打
		INVALID,//无效名单
		ERROR;//异常
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum TagTypeEnum{
		QUALITY;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum StatusTypeEnum{
		INBOUND,			//呼入
		OUTBOUND,			//外呼
		CONTACTS,			//联系人
		BUSSOPP;			//商机
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum LogTypeEnum{
		REQUEST,
		CREATE ,
		READ ,
		UPDATE,
		DELETE,
		OTHER,
		INFO,
		WARN,
		ERROR
		;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum SalesNamesStatus{
		DIST,			//已分配
		NOTDIST;		//未分配
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum LeaveMsgStatus{
		PROCESSED,		//已处理
		NOTPROCESS;		//未处理
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum AdPosEnum{
		POINT,
		IMAGE,
		WELCOME,
		INVITE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum QualityType{
		CHAT,
		VOICE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum QualityStatus{
		NO,		//未开启质检
		DIS,		//已分配
		NODIS,		//未分配
		DONE,     //已质检
		ARCHIVE,   //已归档
		DISABLE,  //无效
		RECHECK,  //复检中
		APPEAL,   //申诉中
		ARBITRATE; //仲裁中
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum TransStatus{
		NO,		//未提交
		SUBMIT,		//已提交
		INTRANS,		//转写中
		SUCCESS,     //成功
		FAILD; //转写失败
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CallCenterCallTypeEnum{
		INSIDELINE,
		ORGINSIDE,
		ORGCALLOUT,
		ORGCALLIN,
		INSIDEQUENE,
		INSIDETRANS,			//已分配
		OUTSIDELINE,
		OUTSIDEQUENE,
		OUTSIDETRANS,
		OUTQUENETRANS,
		INSQUENETRANS;		//未分配
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum CallServiceStatus{
		INQUENE,
		RING,			//振铃
		INCALL,			//应答
		BRIDGE,			//桥接
		HOLD,			//已挂起
		HANGUP;			//已挂机
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CallChannelStatus{
		EARLY,
		DOWN;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum WxMpFileType{
		JPG,
		PNG;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AgentInterType{
		SKILL ,
		AGENT ;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	/**
	 * 会话发起方
	 * @author iceworld
	 *
	 */
	public enum ChatInitiatorType{
		AGENT ,
		USER,
		SYSTEM,
		CANCEL,
		REFUSE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ExtentionType{
		LINE,
		IVR,
		BUSINESS,
		SKILL,
		CONFERENCE,
		QUENE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum DTMFTypeEnum{
		SATISF,
		PASSWORD,		//密码验证
		IDCARD,			//身份证号码
		CARDNO;			//银行卡号
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum AiItemType{
		USERINPUT ,
		AIREPLY;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum MultiUpdateType{
		SAVE ,
		UPDATE,
		DELETE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ReportType{
		REPORT;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum TaskType{
		BATCH,
		ACTIVE,
		QUALITY,
		AISALES,//电销机器人任务
		RECOVERY,//回收
		FORECAST,//预测式外呼拨打任务
		CONTACTS;//联系人
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum WorkOrdersEventType{
		ACCEPTUSER,		//审批人变更
		OTHER;			//其他变更
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum BpmType{
		WORKORDERS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AskOperatorType{
		VIEWS ,
		COMMENTS,
		UPS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ModelType{
		USER ,
		WORKORDERS ,
		KBS,
		SUMMARY,
		CCSUMMARY,WEBIM,CALLOUT,EKM,CONTACTS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum AdapterType{
		TEXT,
		MEDIA,
		AGENT,
		XIAOE,
		INTER;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum MetadataTableType{
		UK_WORKORDERS,
		UK_CONTACTS;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum OnlineUserInviteStatus{
		DEFAULT,
		INVITE,
		REFUSE,
		INSERV,
		ACCEPT;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CustomerTypeEnum{
		ENTERPRISE ,
		PERSONAL ;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum WeiXinEventTypeEnum{
		SUB,
		UNSUB;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum ChannelTypeEnum{
		WEIXIN ,
		WEIXINTP,//微信第三方平台
		WEIBO,
		WEBIM,
		PHONE,
		EMAIL, AI;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum EventTypeEnum{
		SUB ,
		UNSUB,
		MENU;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AgentStatusEnum{
		READY,
		NOTREADY,
		BUSY,
		NOTBUSY,
		IDLE,
		OFFLINE,
		SERVICES, ONLINE, INCALL;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum WorkStatusEnum{
		IDLE,
		WAITTING,
		RING,
		OUTRING,
		INCALL,
		OUTCALL,
		CALLOUT,
		PREVIEW,
		OUTBOUNDCALL,
		FORECAST;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum TaskStatusType{
		NORMAL("0"),
		READ("1"),
		QUEUE("5"),
		RUNNING("2"),
		END("3");

		private String type ;

		TaskStatusType(String type){
			this.type = type ;
		}
		public String getType() {
			return type;
		}

		public void setType(String type) {
			this.type = type;
		}

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum NameSpaceEnum{

		IM("/im/user") ,
		CLOUD("/im/cloud") ,
		AGENT("/im/agent"),
		ENTIM("/im/ent") ,
		AIIM("/im/ai") ,
		CALLCENTER("/callcenter/event");

		private String namespace ;

		public String getNamespace() {
			return namespace;
		}

		public void setNamespace(String namespace) {
			this.namespace = namespace;
		}

		NameSpaceEnum(String namespace){
			this.namespace = namespace ;
		}

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum MessageTypeEnum{
		NEW,
		MESSAGE,
		END,
		TRANS,HUNGUP, STATUS , AGENTSTATUS , SERVICE, WRITING , EXCHANGE , WORKSTATUS;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CallCenterResultStatusEnum{
		OK;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum MediaTypeEnum{
		TEXT,
		EVENT,
		IMAGE,
		VIDIO,
		VOICE,LOCATION, FILE , COOPERATION , ACTION , NEWS, HUNGUP, TRANS,SENSITIVE;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CallTypeEnum{
		IN ,
		OUT,
		SYSTEM,
		INVITE;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum OnlineUserOperatorStatus{
		ONLINE,
		OFFLINE,
		REONLINE,
		CHAT,
		RECHAT,
		BYE,
		SEARCH,
		ACCESS;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum OnlineUserTypeStatus{
		USER,
		WEBIM,
		WEIXIN,
		APP,
		OTHER,
		WEIBO;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AgentUserStatusEnum{
		INSERVICE,
		INQUENE, END  , INVIT , INTRANS;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public static void setApplicationContext(ApplicationContext context){
		applicationContext = context ;
	}

	public static ApplicationContext getContext(){
		return applicationContext ;
	}

	public static ElasticsearchTemplate getTemplet() {
		return templet;
	}

	public static void setTemplet(ElasticsearchTemplate templet) {
		UKDataContext.templet = templet;
	}

	public static int getWebIMPort() {
		return WebIMPort;
	}

	public static void setWebIMPort(int webIMPort) {
		WebIMPort = webIMPort;
	}
	/**
	 * 系统级的加密密码 ， 从CA获取
	 * @return
	 */
	public static String getSystemSecrityPassword(){
		return "UCKeFu" ;
	}

	public static void setIMServerStatus(boolean running){
		imServerRunning = running ;
	}
	public static boolean getIMServerStatus(){
		return imServerRunning;
	}

	public enum FilterConType{
		DIMENSION,
		MEASURE;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	public enum FilterCompType{
		NOT,
		EQUAL;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	public enum FilterValuefilterType{
		COMPARE,
		RANGE;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum FilterConValueType{
		INPUT,
		AUTO,
		USERDEF;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum FilterModelType{
		TEXT,
		DATE,
		SIGSEL,
		SELECT;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum FilteFunType{
		FILTER,
		RANK;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CallType{
		AI,
		AGENT;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AiType{
		SMARTAI,
		BUSINESSAI;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum AiBussType{
		SALE,
		QUESURVEY;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	public enum CallOutType{
		AGENT,
		AI,
		FORECAST;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum BatchTypeEnum{
		PLAN,
		TEMP,
		EXT;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum UCKeFuTopic{
		TOPIC_ENTIM,
		TOPIC_IM,
		TOPIC_AGENT,
		TOPIC_CALLCENTER,
		NAMESPACE,
		TOPIC_JOBDETAIL,
		TOPIC_VOTE;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum EndByType{
		AGENT,
		USER,
		AI,
		TIMEOUT,
		QUEUE,
		SYSTEM,
		END;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum PubStatusEnum{
		NEW,
		WAIT,
		PASS,
		REJECTED,
		DOWN;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AiMatchType{
		FULL,
		KW,
		PART,
		NO,
		CLICK,
		HIGHT,
		SUGGEST;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum KwSearchTypeEnum{
		ORGAN,//部门
		KWTYPE,//知识类型
		TAG,//标签
		DAYSEARCH,//最近1天
		CON;//关键词（搜索框）

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum KnowbaseTypeEnum{
		KNOWLEDGE,//知识库
		HELP,//帮助平台
		ASK;//问答平台

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum QcTemplateStatus{
		START,//启用
		STOP;//停用

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	public enum QcFormFilterTypeEnum{
		CALLEVENT,//通话质检
		WORKORDERS,//工单质检
		AGENTSERVICE;//会话质检（文字客服）

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	public enum QcTemplateItemType{
		PLUS,//评分
		MINUS,//扣分
		TABOO;//禁忌项

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	/**
	 * 	回收类型
	 */
	public enum RecycleType{
		ORGAN,//回收到部门
		PUBLIC;//回收到公共池子

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	/**
	 * 质检分配状态：已分配|未分配
	 * 通话质检，工单质检，会话质检
	 * @author iceworld
	 *
	 */
	public enum QualityDisStatusType{
		NOT,DISAGENT,DISORGAN;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	/**
	 *
	 * @param resource
	 * @return
	 */
	public static Class<?> getResource(String resource){
		return uKeFuResourceMap.get(resource) ;
	}
	/**
	 * 判断是否执行任务，用于扩展规则
	 * @return
	 */
	public static boolean needRunTask() {
		return  ClusterContext.getInstance().isMaster() ;
	}

	/**
	 * 	公告类型
	 * 	业务类型business、系统类型system、平台类型platform
	 *
	 */
	public enum NoticeType{
		BUSINESS,SYSTEM,PLATFORM;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CrmViewType{
		LIST("list","列表"),//列表
		ADD("add","新增"),//新增
		EDIT("edit","修改"),//修改
		DETAIL("detail","详情"),//详情
		BUTTON("button","按钮"),//按钮
		HREF("href","链接"),//链接
		RELATE("relate","关联");//关联
		private String value ;

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		private String key;

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		CrmViewType(String  key, String value){
			this.value = value ;
			this.key = key;
		}

		public static String getValueByKey(String key) {
			CrmViewType[] ViewType = values();
			for (UKDataContext.CrmViewType viewType : ViewType) {
				if (viewType.getKey().equals(key)) {
					return viewType.getValue();
				}
			}
			return null;
		}

		public static Map<String,?> getMap() {
			CrmViewType[] ViewType = values();
			Map<String,String> map = new HashMap<>();
			for (UKDataContext.CrmViewType viewType : ViewType) {
				map.put(viewType.key,viewType.value);
			}
			return map;
		}
	}

	public enum CrmDataModelType{
		PRODUCT("product","产品"),//产品
		MENU("menu","菜单"),//菜单
		SKIP("skip","跳转");//跳转
		private String value ;

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		private String key;

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		CrmDataModelType(String  key, String value){
			this.value = value ;
			this.key = key;
		}

		public static String getValueByKey(String key) {
			CrmDataModelType[] types = values();
			for (UKDataContext.CrmDataModelType type : types) {
				if (type.getKey().equals(key)) {
					return type.getValue();
				}
			}
			return null;
		}

		public static Map<String,?> getMap() {
			CrmDataModelType[] types = values();
			Map<String,String> map = new HashMap<>();
			for (UKDataContext.CrmDataModelType type : types) {
				map.put(type.key,type.value);
			}
			return map;
		}
	}

	public enum CrmButtonActiontypeType{
		TOPRIGHT("0","右上方"),//右上方
		CHECKED("1","数据选中"),//数据选中
		TABLETOP("2","列表上方"),//列表上方
		TABLEROW("3","列表行"),//列表行
		TABLECOL("4","列表列"),//列表列
		TABLEOPERATION("5","列表操作");//列表操作
		private String value ;

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		private String key;

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		CrmButtonActiontypeType(String  key, String value){
			this.value = value ;
			this.key = key;
		}

		public static String getValueByKey(String key) {
			CrmButtonActiontypeType[] types = values();
			for (UKDataContext.CrmButtonActiontypeType type : types) {
				if (type.getKey().equals(key)) {
					return type.getValue();
				}
			}
			return null;
		}

		public static Map<String,?> getMap() {
			CrmButtonActiontypeType[] types = values();
			Map<String,String> map = new HashMap<>();
			for (UKDataContext.CrmButtonActiontypeType type : types) {
				map.put(type.key,type.value);
			}
			return map;
		}
	}

	public enum IvrMenuType{
		MENUEXIT,//转外线
		MENUSUB,//转子菜单
		MENUEXECAPP,//转内线
		MENUPLAYSOUND,//播放语音文件或文本
		MENUBACK,//转上级
		MENUTOP;//转根目录

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum AutoAnswer{
		NONE,//禁用
		ALL,//全部
		QUEUE;//队列

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	
	public enum XiaoEBussOP{
		AGENT,//禁用
		CONTACT,//全部
		SMS,
		WORKORDER;//队列

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	/**
	 * 	敏感词类型
	 *
	 */
	public enum SensitiveWordType{
		AGENT ,
		USER ;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum EsTable{
		UK_CONTACTS,
		UK_CHAT_MESSAGE,
		UK_ONLINEUSER,
		UK_USEREVENT;

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	/*
	 * 数据库类型
	 */
	public enum DriverClassName{
		MYSQL("com.mysql.jdbc.Driver"),
		ORACLE("oracle.jdbc.driver.OracleDriver");

		private String type ;

		DriverClassName(String type){
			this.type = type ;
		}
		public String getType() {
			return type;
		}

		public void setType(String type) {
			this.type = type;
		}

		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum CrmDefaultLayoutType{
		SUMMARY , 
		RELATE ,
		INFO,
		BUTTON,
		FORM;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}

	public enum MenuButtonType{
		CLICK("click","点击推事件"),//右上方
		VIEW("view","跳转URL"),//数据选中
		MINIPROGRAM("miniprogram","跳转到小程序"),//列表上方
		SCANCODE_PUSH("scancode_push","扫码推事件"),//列表行
		SCANCODE_WAITMSG("scancode_waitmsg","扫码推事件且弹出“消息接收中”提示框"),//列表列
		PIC_PHOTO_OR_ALBUM("pic_photo_or_album","弹出拍照或者相册发图"),//列表列
		PIC_WEIXIN("pic_weixin","弹出微信相册发图器"),//列表列
		LOCATION_SELECT("location_select","弹出地理位置选择器"),//列表列
		MEDIA_ID("media_id","下发消息（除文本消息）"),//列表列
		VIEW_LIMITED("view_limited","图文信息"),//列表列
		PIC_SYSPHOTO("pic_sysphoto","弹出系统拍照发图");//列表操作
		private String value ;

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		private String key;

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		MenuButtonType(String  key, String value){
			this.value = value ;
			this.key = key;
		}
		

		public static String getValueByKey(String key) {
			MenuButtonType[] types = values();
			for (UKDataContext.MenuButtonType type : types) {
				if (type.getKey().equals(key)) {
					return type.getValue();
				}
			}
			return null;
		}

		public static Map<String,?> getMap() {
			MenuButtonType[] types = values();
			Map<String,String> map = new HashMap<>();
			for (UKDataContext.MenuButtonType type : types) {
				map.put(type.key,type.value);
			}
			return map;
		}
	}
	
	public static RuntimeData getRuntimeData() {
		return runtimeData ;
	}
	
	public enum ContactsItemType{
		CONTACTS , 
		CUSTOMER ;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	
	
	public enum BussType{
		
		CONTACTS("uk_contacts") ;
		
		private String metadata ;
		BussType(String metadata){
			this.metadata = metadata ;
		}
		public String getMetadata() {
			return metadata;
		}
		public void setMetadata(String metadata) {
			this.metadata = metadata;
		}


		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}


	//话术 匹配答案 类型
	public enum AnswerType{
		ANSWER,		//节点答案
		ANSWER_INTERRUPT,		//节点 打断 答案
		ANSWER_PUBLIC,		//公共答案
		ANSWER_PUBLIC_INTERRUPT,		//公共答案 打断 答案
		REPEAT,		//匹配重复
		ERROR,//匹配错误
		OVERTIME,
		UNMATCH;	//未匹配
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	
	public enum ContactsJobDetailType{
		DIS,
		RECYCLE;
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	
	public enum QualityResult{
		PASS,			//通过
		FAILD;		//未通过
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	

	public enum PortalType{
		WEBIM,			//通过
		CONTACTS;		//未通过
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
	public enum ContactsHangupcaseType{
		EMPNO,			//空错号
		NOANSWER,		//振铃，无人接听
		OTHER;	//其他原因
		public String toString(){
			return super.toString().toLowerCase() ;
		}
	}
}
